package example;

import basic.JodisDb;
import protocol.ProtocolConstant;
import protocol.Request;
import protocol.Response;
import server.JodisConfig;
import utils.PropertiesUtils;

import javax.naming.ConfigurationException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

public class StringOperationTest {
    public static void main(String[] args) throws IOException, ConfigurationException {
//        EmbaddedJodis jodis = EmbaddedJodis.start("E:\\java\\Jodis-master\\src\\main\\java\\cn\\abelib\\jodis\\conf\\jodis.properties");

        Properties mainProperties = PropertiesUtils.loadProps("E:\\jodis.properties");
        JodisConfig config = new JodisConfig(mainProperties);

        JodisDb jodisDb = new JodisDb(config);
        List<String> arguments = new ArrayList<>();
        arguments.add("key1");arguments.add("hello");
        Request request = new Request(ProtocolConstant.STRING_SET, arguments);
        request.setRequest("set key1 hello");
        Response response = jodisDb.execute(request);
        System.out.println(response.toRespString());


        List<String> getArguments = new ArrayList<>();
        getArguments.add("key1");
        Request request1 = new Request(ProtocolConstant.STRING_GET, getArguments);
        Response response1 = jodisDb.execute(request1);
        System.out.println(response1.toRespString());
    }
}
